<template>
  <div class="all_box">
    <div class="login_box">
      <div class="box_text">
        <div class="box_text01"><h1
            style="font-weight: bolder;
            font-size:40px;
            color: aliceblue"
        >GX-games赛事管理平台</h1></div>
        <div class="box_text02"><p style="font-size:20px;
        font-weight: bolder;
        color: aliceblue"
        >通过对多次参赛经验的总结，使用MVVM开发模式，搭建起一整套基于赛事流程与后台管理的赛事管理信息系统，提供赛事举办的标准模块与执行流程，实现赛事的发布、报名、提交作品、下载作品、作品评分等功能。该系统有弔开发团队独立开发，系统仍在持续升级中。</p></div>
    </div>
    <div class="user_box">
      <div class="user_boxTop"><span>欢迎登陆</span></div>
      <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" class="demo-ruleForm">
        <el-form-item prop="name">
          <el-input prefix-icon="el-icon-user" type="text" v-model="ruleForm.username"  placeholder="请输入用户名" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item prop="pass">
          <el-input prefix-icon="el-icon-unlock" type="password" v-model="ruleForm.password" placeholder="请输入密码" show-password autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submitForm('ruleForm')" class="handleButton">登陆</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="resetForm()" class="handleButton">注册</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div class="main_about">
      <div class="about_title"><h1>关于我们</h1></div>
      <div class="about_text">
        <div class="about_text_left">
          <h2 style="text-align: center">开发团队</h2>
          <p style="text-indent: 2em;">开发团队主要有三人，皆为在校大学生。他们分别是前端负责人白给，后端负责人悲伤炒酸奶，UI负责人Echo。</p>
        </div>
        <div style="width: 45px; display: inline-block"></div>
        <div class="about_text_middle">
          <h2 style="text-align: center">平台介绍</h2>
          <p style="text-indent: 2em;">这是一个集比赛发布、报名、资讯、比赛评分等功能与一体的赛事管理平台，更多功能正在持续开发中，尽情期待。</p>
        </div>
        <div style="width: 45px; display: inline-block"></div>
        <div class="about_text_right">
          <h2 style="text-align: center">持续更新</h2>
          <p style="text-indent: 2em;">平台后端使用了时下最流行的springboot+mybatisPlus框架进行开发。前端采用了vue2 ElementUI框架进行开发。</p>
        </div>
      </div>
    </div>

    <div class="home_footer">
      <div class="footer_litlebox">
        <div class="footer_site">
          <i class="el-icon-location footer_text"></i>
          <span class="footer_text">地址：重庆市合川区假日大道1号重庆移通学院</span>
        </div>
        <div class="footer_mailbox">
          <i class="el-icon-message footer_text"></i>
          <div class="footer_text">邮箱：1628206678@qq.com</div>
        </div>
        <div class="footer_phone">
          <i class="el-icon-phone footer_text"></i>
          <div class="footer_text">电话：021-81239657</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    //密码验证
    let validateName = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入你的账户名称'));
      }
        callback();
    };
    let validatePass = (rule, value, callback) => {
      if (value === '') {
        callback(new Error('请输入密码'));
      }
        callback();
    };
    return {
      ruleForm: {
        username: '',
        password: '',
      },
      rules: {
        name: [
          { validator: validateName, trigger: 'blur' }
        ],
        pass: [
          { validator: validatePass, trigger: 'blur' }
        ]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$api.login(this.ruleForm).
            then(res=>{
            if (res.state) {
              window.sessionStorage.setItem("token",res.token);
              window.sessionStorage.setItem('level',res.level);
              window.sessionStorage.setItem("userName",this.ruleForm.username);
              window.sessionStorage.setItem('userID',res.userId);
              this.$router.push("/home");
              } else {
                alert("账号或密码错误")
              }
            }).catch(err=>{
              alert("请求失败请稍后重试！")
              console.log(err);
            })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm() {
      this.$router.push('/userRegister')
    }
  }
}
</script>

<style lang="less" scoped>
.all_box{
  //background-color: #cbc5c5;
  background-image: url("../../imgs/login_background2.jpg");
  background-repeat: no-repeat;
  background-position: right top;
  background-size: 2400px 700px;
  margin:0;
  padding:0;
  height: 700px;
  .login_box{
    width: 1000px;
    height: 600px;
    //border: 1px solid red;
    margin: 0 auto;
    position: relative;
    .box_text{
      width: 600px;
      height: 300px;
      position: absolute;
      top: 150px;
      //border: 1px solid red;
    }
    .user_box{
      border-radius: 6px;
      height: 500px;
      width: 300px;
      margin-top: 50px;
      //box-shadow:2px 2px 3px #ffffff;
      background-color: #ffffff;
      float: right;
      .user_boxTop{
        box-sizing: border-box;
        width: 100%;
        height: 60px;
        line-height: 60px;
        padding: 0 20px;
        font-weight: bold;
        border-bottom: 1px solid #ded7d7;
      }
      .demo-ruleForm{
        margin-top: 40px;
        padding: 0 20px;
        .handleButton{
          width: 100%;
          font-size: 20px;
        }
      }
    }
  }
  .main_about{
    margin-top: 150px;
    padding-bottom: 65px;
    .about_title{
      text-align: center;
    }
    .about_text{
      width: 880px;
      //padding: 50px;
      margin: 0 auto;
      .about_text_left, .about_text_middle, .about_text_right{
        display: inline-block;
        background-color: #f5f7fa;
        border: 1px solid lavender;
        padding: 0 10px;
        border-radius: 6px;
        box-shadow: 0 0 2px 2px #fff;
        //text-align: center;
        width: 240px;
        height: 400px;
      }
    }
  }
  .home_footer{
    background-color: #545c64;
    height: 150px;
  }
  .footer_litlebox{
    //margin: 0 auto;
    padding: 50px 0;
    .footer_site, .footer_mailbox, .footer_phone{
      display: inline-block;
      height: 50px;
      width: 30%;
      padding: 0 1.5%;
      margin: 0 auto;
      text-align: center;
      .footer_text{
        display: inline-block;
        font-weight: lighter;
        font-size: 20px;
        color: #909399;
      }
    }
  }
}
</style>
